﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DiArte.Data.Catalog
{
    public class AttributeValuePriceDal : BaseDal
    {
        /// <summary>
        /// Deletes all attribute value prices
        /// </summary>
        public void DeleteAll()
        {
            using (var command = new Npgsql.NpgsqlCommand("DELETE FROM attribute_value_price"))
                PerformCommand(command);
        }

        /// <summary>
        /// Inserts a new attribute value price
        /// </summary>
        /// <param name="attributeValueId">The attribute value id</param>
        /// <param name="storeId">The store id</param>
        /// <param name="value">The value</param>
        /// <param name="currency">The currency</param>
        public void Insert(int attributeValueId, int storeId, double value, String currency)
        {
            using (var command = new Npgsql.NpgsqlCommand("INSERT INTO attribute_value_price(attribute_value_price_id, attribute_value_id, store_id, value, currency) VALUES " +
                "(nextval('attribute_value_price_id_sequence'), :attribute_value_id, :store_id, :value, :currency)"))
            {
                command.Parameters.AddWithValue("attribute_value_id", attributeValueId);
                command.Parameters.AddWithValue("store_id", storeId);
                command.Parameters.AddWithValue("value", value);
                command.Parameters.AddWithValue("currency", currency);

                PerformCommand(command);
            }
        }

    }
}
